      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
          <ol class="breadcrumb">
            <li><a href="<?=site_url()?>/order/index">订单管理</a></li>
            <li class="active">分配送货员</li>
          </ol>
         
          <div class="row">
            <div class="col-md-12">
              <div class="table-responsive">
                <h4 class="margin-bottom-15">分配送货员</h4>
                 <form role="form" id="templatemo-preferences-form" onsubmit="return false;">
                <div class="row">
                	<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">订单号</label> <input
									type="text" class="form-control" id="orderid" value="<?=$orderid?>" readonly="readonly">
					</div>
                   <div class="col-md-6 margin-bottom-15">
                    <label for="lastName" class="control-label">选择送货员</label>
                    <select class="form-control margin-bottom-15" id="delivery">
							<?php foreach ($deliverymans as $item):?>
                    			<option value="<?php echo $item['id'];?>" ><?php echo $item['name'];?></option>
                     		<?php endforeach;?>
					</select>                 
                  </div>
	              </div>
	              <div class="row templatemo-form-buttons">
	                <div class="col-md-12">
	                  <button type="submit" class="btn btn-primary" id="submit_btn">分配</button>
	                </div>
                </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
<script>
	$(document).ready(function() {
		$("#submit_btn").click(function() {
			var orderid = $("#orderid").val();
			var delivery = $("#delivery").val();
			$.ajax({
				url : '<?php echo site_url('order/setdelivery')?>',
				type : "post",
				async : true,
				data : {
					'orderid' : orderid,
					'delivery' : delivery
				},
				dataType : "json",
				timeout : "1000",
				error : function() {
					alert("服务加载出错");
				},
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
						window.location.href="<?php echo site_url('order/index')?>";
					}else{
						alert(data.msg);
					}
				}
			});
		});
	}); 
</script>